<div class="breadcrumb">
    <ul id="breadcrumb">
        <li><a href="<?php echo Configure::read('base_url');?>backstage" title="Home">
		<?php echo $this->Html->image("home.png", array("alt" => "Home",'class'=>'home','border'=>'0'));?>
		</a></li>
        <li><a href="<?php echo Configure::read('base_url');?>backstage/users" title="Manage Admin">Manage Q-Admin</a></li>
        <li>Q-Admin Summary Page</li>
    </ul>
</div>
<?php echo $this->element('admin/admin_leftmenu'); ?>
<div id="left"> 
    <?php
		echo $this->Session->flash();
		if ($this->Session->check('Message.auth'))
        echo $this->Session->flash('auth');
    ?>
    <br class="clear" />
    <div class="div_header"><?php __('Summary page of '.$users['User']['username']);?></div>
    <div class="div_content">
		<table id="category_table" cellspacing="0" class="tablesorter">
			<thead>
				<tr>
					<th align="center"><?php echo _('Period'); ?></th>
					<th align="center"><?php echo _('Products Approved'); ?></th>
					<th align="center"><?php echo _('Products Sold'); ?></th>
					<th align="center"><?php echo _('Total'); ?></th>
					<th align="center">Status</th>
					<th align="center">Pay Date</th>
					<th align="center">Pay Now</th>
				</tr>
			</thead>
			<tbody>
        <?php if($summaries){
				$i=0;
				foreach($summaries as $summary){
				$class ="";
                if ($i++ % 2 == 0)
				    $class = ' class="alt"';
				?>   
				<tr>
					<td align="center" <?php echo $class;?>><?php echo date("m/d/Y",strtotime($summary['QadminSummary']['period1']))." - ".date("m/d/Y",strtotime($summary['QadminSummary']['period2'])); ?></td>
					<td align="center" <?php echo $class;?>><?php echo $summary['QadminSummary']['products_approved']; ?></td>
                    <td align="center" <?php echo $class;?>>
						<a href="<?php echo Configure::read('base_url');?>backstage/users/qadmin_sold/<?php echo $summary['QadminSummary']['id'];?>">
						<?php echo $summary['QadminSummary']['product_sold']; ?>
                        </a>
                    </td>
                    <td align="center" <?php echo $class;?>>$<?php echo $summary['QadminSummary']['total'];?></td>
                    <td align="center" <?php echo $class;?>><?php echo $summary['QadminSummary']['status'];?></td>
                    <td align="center" <?php echo $class;?>><?php if($summary['QadminSummary']['pay_date']) echo date("m/d/Y",strtotime($summary['QadminSummary']['pay_date']));else echo"-";?></td>
                    <td align="center" <?php echo $class;?>>
						<?php if($summary['QadminSummary']['cheque_no'])
								echo "cheque #: ".$summary['QadminSummary']['cheque_no'];
							else{?>
						<form action="<?php echo Configure::read('base_url');?>backstage/users/qadmin_summary/<?php echo $users['User']['id'];?>" method="POST">
						<?php echo $this->Form->input('QadminSummary.id',array('type'=>'hidden','value'=>$summary['QadminSummary']['id']));
							echo $this->Form->input('QadminSummary.cheque_no',array('type'=>'text','div'=>false,'label'=>false));	
							?>
							<input type="submit" name="submit" value="Paid" />
							</form>	
						<?php	}	?>
					</td>
                </tr>
		<?php $i++;}}else{?>
		<tr><td colspan="7">No summary found for <?php echo $users['User']['username'];?></td></tr>
		<?php } ?>        
			</tbody>
		</table>
		<div class="paging">
			<?php echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
				&nbsp;|&nbsp;<?php echo $this->Paginator->numbers();?>
			&nbsp;|&nbsp;<?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
		</div>
    </div>
    <div class="div_bottom"></div>
</div>
<?php  echo $html->script(array("jquery.pagination.js","jquery.tablesorter.min.js","jquery.tablednd.js")); ?>	 
 <script type="text/javascript">  
 jQuery(document).ready(function(){
 jQuery("#category_table").tablesorter(); 
 });	
 </script>